Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


docs/agents/skills/meshchat-orchestration-split/SKILL.md HEAD (b89dc9e6) Text, 3.54 KB

Skill: meshchat-orchestration-split

Extract or split HTTP routes and WebSocket handlers under T383838meshchatx/src/backend/http/
without changing behaviour.

When to use

• Splitting or moving handlers among T383838routes/<domain>.py modules
• Moving WS inbound dispatch pieces among T383838ws/handlers_*.py
• Adding new HTTP endpoints or WS message types in the extracted layout

Also read:

• T383838docs/agents/module-ownership.md
• T383838docs/agents/conventions/backend.md
• T383838docs/agents/conventions/tests.md

Hard rules

1. Mechanical extract only. No renames, no error-map tweaks, no new logging in the same change as a move.
2. One concern per change: move or behaviour, never both.
3. Keep public entrypoints:
• T383838from meshchatx.meshchat import ReticulumMeshChat, main
• T383838get_routes() and T383838_define_routes(routes) return shape
• middleware order: T383838auth, T383838mime_type, T383838security, T383838csrf, T383838ip_allowlist
4. Handlers use T383838app where the original used T383838self.
5. No new business logic in route modules. Parse, call manager or app method, return response.
6. Identity lifecycle and LXMF callbacks stay on T383838ReticulumMeshChat until lifecycle packaging.
7. Follow inventory names in T383838docs/agents/module-ownership.md. Do not invent alternate folders.
8. Domain splits start from existing T383838routes/<domain>.py modules or residual shared helpers.
Do not re-extract routes from T383838meshchat.py.
9. One-shot extract scripts that rewrote T383838meshchat.py were removed. Do not revive them.

Layout

Current:

T282828
meshchatx/src/backend/http/
context.py
errors.py
live_names.py
meshchat_names.py
middleware.py
register.py
routes/<domain>.py
routes/__init__.py
ws/dispatch.py
ws/handlers_*.py

Pattern:

T282828
Tff7b72def Td2a8ffregister_status_routesTb4b4b4(Te6edf3routesTb4b4b4, Te6edf3appTb4b4b4)Tb4b4b4:
Tf0883e@routesTff7b72.Td2a8ffgetTb4b4b4(Ta5d6ff"Ta5d6ff/api/v1/statusTa5d6ff"Tb4b4b4)
Tff7b72async Tff7b72def Td2a8ffstatusTb4b4b4(Te6edf3requestTb4b4b4)Tb4b4b4:
Tff7b72.Tff7b72.Tff7b72.


T383838register.py calls T383838register_extracted_routes, which binds meshchat free names via
T383838live_names.inject_meshchat_names so T383838patch("meshchatx.meshchat.<symbol>") still applies.

Lazy-import T383838register_all_routes from inside T383838_define_routes so route modules load after
meshchat is initialized.

Contract scanners

Scanners must cover:

• T383838meshchatx/meshchat.py
• T383838meshchatx/src/backend/http/**/*.py
• lifecycle modules for broadcast payloads where relevant

HTTP: T383838tests/backend/http_api_contract_helpers.py (T383838extract_meshchat_http_routes).

WS: T383838tests/backend/ws_contract_helpers.py (inbound, direct responses, broadcast).

Update fixtures only when inventory intentionally changes:

T282828
Te6edf3UPDATE_HTTP_API_ROUTESTff7b72=T79c0ff1 uv run pytest tests/backend/test_http_api_contract.py -k meshchat_http_routes_match_fixture
Te6edf3UPDATE_WS_MESSAGE_MANIFESTTff7b72=T79c0ff1 uv run pytest tests/backend/test_ws_json_contracts.py -k manifest_matches_meshchat


Verification

After each domain move:

T282828
uv run pytest tests/backend/test_http_api_contract.py Tffea00\
tests/backend/test_api_json_contracts.py Tffea00\
tests/backend/test_http_api_json_contracts_broad.py Tffea00\
tests/backend/test_ws_json_contracts.py -q --tbTff7b72=short


Also run domain tests for the moved area and T383838task test:quick at milestones.

Before declaring a large milestone done: T383838task test:backend and T383838task test:frontend.

Compatibility patches

Tests often use T383838patch("meshchatx.meshchat.<symbol>"). Keep those symbols importable from
T383838meshchatx.meshchat (re-export if moved). Live name proxies live in T383838backend/http/live_names.py.

T383838ReticulumMeshChat.on_websocket_data_received is a one-line delegate to T383838http/ws/dispatch.py.


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────